package com.funtl.oauth2.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;

/**
 * 基于内存
 *
 * @Author: wumz
 * @Date: 2020/8/6 10:14
 * @Version 1.0
 */
//@Configuration
//@EnableAuthorizationServer
public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter {

    @Autowired
    private BCryptPasswordEncoder passwordEncoder;

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()  // 使用内存设置

                .withClient(passwordEncoder.encode("client"))   // 你的client_id

                .secret(passwordEncoder.encode("secret"))   // 你的client_secret

                .authorizedGrantTypes("authorization_code") //授权类型

                .scopes("app")  //授权范围

                .redirectUris("https://gitee.com/wwumz/spring-security-oauth2");    //注册回调地址
    }
}
